/*
 * HomeNoticeListItem.java
 * business
 *
 * Created by ChenTao on 2017/1/16.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.displaylistitem;

import android.app.Activity;
import android.content.Context;
import android.widget.TextView;

import com.yidiandao.business.data.imagemodule.Notice;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;
import com.yidiandao.business.ui.widget.listview.viewholder.HomeNoticeHolder;
import com.yidiandao.business.ui.widget.view.NoticeView;
import com.yidiandao.business.utils.JumpUtils;

import java.util.ArrayList;
import java.util.List;

/** 首页-公告-ListItem */
public class HomeNoticeListItem extends DisplayListItem<HomeNoticeHolder, List<Notice>> {

    private Activity mActivity;

    private List<String> mNoticeUrls;

    public HomeNoticeListItem(List<Notice> s) {
        super(s);
        mNoticeUrls = new ArrayList<>();
    }

    @Override
    public void onShow(Context context, HomeNoticeHolder holder) {
        mActivity = (Activity) context;

        mNoticeUrls.clear();
        for (Notice notice : data) {
            mNoticeUrls.add(notice.getContent());
        }
        holder.setNoticeData(mNoticeUrls);

        holder.marqueeView.setOnItemClickListener(
                new NoticeView.OnItemClickListener() {
                    @Override
                    public void onItemClick(TextView view, int position) {
                        JumpUtils.clickNotice(mActivity, data.get(position));
                    }
                });
    }

    @Override
    public String getDisplayItemTag() {
        return HomeNoticeListItem.class.getSimpleName();
    }

    @Override
    public Class<HomeNoticeHolder> getViewHolderClazz() {
        return HomeNoticeHolder.class;
    }
}
